package fivm.cross.platform.steamobj.appcase;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import fivm.cross.platform.ficommon.distinguish.GsonSimpleSerializable;
import fivm.cross.platform.steamobj.appcase.params.FiServerConnectivityManager;
import fivm.cross.platform.steamobj.appcase.params.FiServerTelephonyManager;
import fivm.cross.platform.steamobj.appcase.params.FiServerWifiInfo;
import fivm.cross.platform.steamobj.appcase.params.FiServerWifiManagerManager;

import java.util.HashMap;

/**
 * Created by Administrator on 2016/5/18.
 */
public class DroidParamsStream extends GsonSimpleSerializable{
    @Expose @SerializedName("ParamC")
    private HashMap<String,String> paramC=new HashMap<String,String>(); //C参数的处理方法
    @Expose @SerializedName("ParamJava")
    private FiParamJava paramJava;

    public HashMap<String, String> getParamC() {
        return paramC;
    }

    public void addParamCvalue(String key,String value){
        paramC.put(key,value);
    }
    public void setParamC(HashMap<String, String> paramC) {
        this.paramC = paramC;
    }

    public FiParamJava getParamJava() {
        return paramJava;
    }

    public void setParamJava(FiParamJava paramJava) {
        this.paramJava = paramJava;
    }

    public static class FiParamJava extends GsonSimpleSerializable {
        @Expose @SerializedName("TelephonyManager")
        private FiServerTelephonyManager TelephonyManager;
        @Expose @SerializedName("ConnectivityManager")
        private FiServerWifiManagerManager WifiManagerManager;
        @Expose @SerializedName("WifiManagerManager")
        private FiServerConnectivityManager ConnectivityManager;

        public FiServerTelephonyManager getTelephonyManager() {
            return TelephonyManager;
        }

        /**
         * 生成一组新的参数
         */
        public static FiParamJava generateNewParam(String imsi,String imei,String Mac,String BssId,
                                                   String Ssid){
            //构造wifiInfo
            FiServerWifiInfo wifiInfo=new FiServerWifiInfo();
            {
                if(Mac==null || Mac.equals("")){
                    Mac=wifiInfo.genMac();
                }

                if(BssId==null || BssId.equals("")){
                    BssId=wifiInfo.genMac();
                }
                if(Ssid ==null || Ssid.equals("")){
                    Ssid =wifiInfo.genSsid();
                }
                wifiInfo.setMAC(Mac);
                wifiInfo.setBSSID(BssId);
                wifiInfo.setSSID(Ssid);
            }
            //构造WifiManagerManager
            FiServerWifiManagerManager wifiManagerManager=new FiServerWifiManagerManager();
            wifiManagerManager.setWifiInfo(wifiInfo);
            //构造TelephonyManager
            FiServerTelephonyManager telephonyManager=new FiServerTelephonyManager();
            {
                if(imei==null || imei.equals("")){//imei应该是在这里设置的
                    imei=telephonyManager.genImei();
                }
                telephonyManager.setDeviceId(imei);
                if(imsi==null || imsi.equals("")){
                    imsi=telephonyManager.genImsi();
                }
                telephonyManager.setSimOperator(imsi.substring(0,5));
                telephonyManager.setSubscriberId(imsi);
            }
            //构造ConnectivityManager
            FiServerConnectivityManager connectivityManager=new FiServerConnectivityManager();
            //将参数ParamJava整合一起
            FiParamJava retDroidParams=new FiParamJava();
            retDroidParams.setTelephonyManager(telephonyManager);
            retDroidParams.setWifiManagerManager(wifiManagerManager);
            retDroidParams.setConnectivityManager(connectivityManager);
            return retDroidParams;
        }




        public void setTelephonyManager(FiServerTelephonyManager telephonyManager) {
            TelephonyManager = telephonyManager;
        }

        public FiServerWifiManagerManager getWifiManagerManager() {
            return WifiManagerManager;
        }

        public void setWifiManagerManager(FiServerWifiManagerManager wifiManagerManager) {
            WifiManagerManager = wifiManagerManager;
        }

        public FiServerConnectivityManager getConnectivityManager() {
            return ConnectivityManager;
        }

        public void setConnectivityManager(FiServerConnectivityManager connectivityManager) {
            ConnectivityManager = connectivityManager;
        }
    }

}
